//
//  YKEmotinoButton.m
//  youkan
//
//  Created by 吴高烽 on 16/5/3.
//  Copyright © 2016年 Honsintech. All rights reserved.
//

#import "YKEmotinoButton.h"
#import "YKEmotions.h"
@implementation YKEmotinoButton
/**
 *  当控件不是通过xib或storyboard中创建时，就会调用该方法。
 *
 */
-(instancetype)initWithFrame:(CGRect)frame{
    if (self =[super initWithFrame:frame]) {
        [self setUp];
    }
    return self;
}
// 当一个对象从文件中解析出来的时候回调用这个方法，比如xib，比awakeFromNib先调用
-(instancetype)initWithCoder:(NSCoder *)aDecoder{
    self=[super initWithCoder:aDecoder];
    if (self) {
        [self setUp];
    }
    return self;
}
-(void)setUp{
    self.titleLabel.font =[UIFont systemFontOfSize:32];
    //!> 调整点击图片时的高亮状态
    self.adjustsImageWhenHighlighted = NO ;
}
/**
 *  在initWithCoder:方法后调用
 */
-(void)awakeFromNib{
    [super awakeFromNib];
    [self setUp];
}
-(void)setEmotion:(YKEmotions *)emotion{
    _emotion = emotion ;
    if (emotion.png) {
        [self setImage:[UIImage imageNamed:emotion.png] forState:UIControlStateNormal];
    }else{
        [self setTitle:emotion.code.emoji forState:UIControlStateNormal];
    }
}
//-(void)setHighlighted:(BOOL)highlighted{
//}
@end
